﻿<UserControl x:Class="SqlExport.View.StatusPanelView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Converters="clr-namespace:SqlExport.View.Converters"
             xmlns:viewModel="clr-namespace:SqlExport.ViewModel"
             mc:Ignorable="d"
             Padding="0" 
             Margin="0"
             d:DataContext="{d:DesignInstance viewModel:StatusPanelViewModel, IsDesignTimeCreatable=True}"
             DataContext="{Binding StatusPanelViewModel, Source={StaticResource Locator}}">
    <Grid>
        <Grid.Resources>
            <ResourceDictionary>
                <Converters:ElapsedTimeValueConverter x:Key="ElapsedTimeValueConverter"/>
                <Converters:CaretToSelectedTextValueConverter x:Key="SelectedTextValueConverter"/>
                <Converters:RecordCountValueConverter x:Key="RecordCountValueConverter"/>

                <Style TargetType="{x:Type Label}">
                    <Setter Property="Padding" Value="1,0,1,0" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                </Style>

                <Style BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" TargetType="Separator">
                    <Setter Property="Margin" Value="2,0"/>
                </Style>
            </ResourceDictionary>
        </Grid.Resources>
        <StatusBar Grid.Column="1" Background="Transparent">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem>
                <StackPanel Orientation="Horizontal">
                    <ComboBox ItemsSource="{Binding Databases}" SelectedItem="{Binding SelectedDatabase, UpdateSourceTrigger=PropertyChanged}" 
                              Style="{StaticResource DatabaseList}"/>
                    <Separator/>
                </StackPanel>
            </StatusBarItem>
            <StatusBarItem Grid.Column="1">
                <Label Content="{Binding Status}" />
            </StatusBarItem>
            <StatusBarItem Grid.Column="2">
                <StackPanel Orientation="Horizontal">
                    <Separator/>
                    <Label Content="{Binding RecordCount, Converter={StaticResource RecordCountValueConverter}}" MinWidth="90" />
                    <Separator/>
                    <Label Content="{Binding ElapsedTime, Converter={StaticResource ElapsedTimeValueConverter}}" MinWidth="90" />
                    <Separator/>
                    <Label Content="{Binding Caret, Converter={StaticResource SelectedTextValueConverter}}" Padding="1,0,3,0" />
                </StackPanel>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</UserControl>
